home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
EXT
/
A-E
/
AutoCruise.cpt
/
AutoCruise ƒ
/
AutoCruise (Source)
/
Init.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-10-07
|
2KB
|
70 lines
/* Init.c */
/*
* The init resource that installs the patch for the AutoCruise Mouse.
* Be sure to set the attributes bits so this INIT resource is locked.
* INIT 31 fails to do this for us.
*/
#include "Cruise.h"
static crsrTaskVarsP varsAddress;
static long scratch;
main()
{
asm /* Real men do it in assembly. */
{
clr.l DeskHook /* Why? Because DTS says so. */
move.l #sizeof(crsrTaskVars),d0
_NewPtr SYS+CLEAR
move.l a0,varsAddress /* remember where it is for later */
move.l jCrsrTask,OFFSET(crsrTaskVars,OldCrsrTask)(a0) /* save old task */
}
scratch=(long)GetResource('COOL',128);
DetachResource(scratch);
/*
* init variables. This prevents the cursor from jumping wildly
* around the screen at bootup. It isn't strictly necessary, but it
* doesn't hurt.
*/
varsAddress->Prevh=(Mouse.h)<<3;
varsAddress->Prevv=(Mouse.v)<<3;
varsAddress->PrevInth=Mouse.h;
varsAddress->PrevIntv=Mouse.v;
varsAddress->LastTimeh=Ticks;
varsAddress->LastTimev=Ticks;
/*
* Slightly specialized stuff. Basically, we install the patch
* by modifing some zero page globals.
*/
asm
{
move.l scratch,a0 /* get saved handle */
move.l (a0),a0 /* deref handle */
move.l varsAddress,(a0) /* tell patch where to find its vars */
addq.l #4,a0
move.l a0,jCrsrTask /* tell system about patch */
}
}
/*
* Notice than an application or cdev can check to see if this patch
* is installed by the following neat trick:
*
* Pointer *aPtr;
*
* aPtr=(Pointer *)jCrsrTask;
* aPtr--; *** remember, '--' (of a pointer pointer) -> '-=4' ***
* if (GetPointerSize(*aPtr)==sizeof(crsrTaskVars))
* { It's installed }
* else
* { It's not installed }
*/